package com.resource.authoritymanage.controller;

import java.util.Arrays;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.resource.authoritymanage.config.ApplyStatusEnum;
import com.resource.authoritymanage.entity.TIdentifyApplyEntity;
import com.resource.authoritymanage.service.TIdentifyApplyService;
import com.resource.common.utils.AppResponse;
import com.resource.common.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.resource.common.utils.PageUtils;


/**
 * 用户授权申请表
 *
 * @author zkx
 * @email 1486664603@qq.com
 * @date 2023-03-06 20:53:55
 */
@RestController
@RequestMapping("/authority/tidentifyapply")
public class TIdentifyApplyController {
    @Autowired
    private TIdentifyApplyService tIdentifyApplyService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = tIdentifyApplyService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        TIdentifyApplyEntity tIdentifyApply = tIdentifyApplyService.getById(id);
        return R.ok().put("tIdentifyApply", tIdentifyApply);
    }

    /**
     * 保存审批申请信息
     */
    @RequestMapping("/save")
    public R save(@RequestBody TIdentifyApplyEntity tIdentifyApply) {
        //申请状态（待申请）
        tIdentifyApply.setApplyStatus(ApplyStatusEnum.PEND_APPLY.getCode());
        tIdentifyApplyService.save(tIdentifyApply);
        return R.ok();
    }

    /**
     * 提交审批申请信息
     */
    @RequestMapping("/submit")
    public R submit(@RequestBody TIdentifyApplyEntity tIdentifyApply) {
        //申请状态（申请中）
        tIdentifyApply.setApplyStatus(ApplyStatusEnum.APPLYING.getCode());
        tIdentifyApplyService.submit(tIdentifyApply);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TIdentifyApplyEntity tIdentifyApply) {
        tIdentifyApplyService.updateById(tIdentifyApply);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
        tIdentifyApplyService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
